//
//  AddDoctorViewController.m
//  安好
//
//  Created by qinlongqing on 14/12/4.
//  Copyright (c) 2014年 lianchuangbrother. All rights reserved.
//

#import "AddDoctorViewController.h"
#import "FKSearchBar.h"
#import "ConsultDocListViewController.h"
#import "SearchDoctorsResultViewController.h"

@interface AddDoctorViewController ()<FKSearchBarDelegate>
{
    FKSearchBar *searchBar;
}
@end

@implementation AddDoctorViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = UIColorFromRGB(0xf2f2f2);

    [self makeNavBar];
    
    searchBar = [[FKSearchBar alloc]init];
//    if (kScreenWidth == 414) {
//        searchBar.frame = CGRectMake(0, 0, kScreenWidth, 60);
//    }
//    else{
        searchBar.frame = CGRectMake(0, 0, kScreenWidth, 50);
//    }
    searchBar.fkSearchRequestDelegate = self;
    [self.view addSubview:searchBar];
    
    UIView *nearbyDoctorView = [[UIView alloc]init];
    if (kScreenWidth == 414) {
        nearbyDoctorView.frame = CGRectMake(0, searchBar.frame.origin.y + searchBar.frame.size.height, kScreenWidth, 50);
    }
    else{
        nearbyDoctorView.frame = CGRectMake(0, searchBar.frame.origin.y + searchBar.frame.size.height, kScreenWidth, 42);
    }
    nearbyDoctorView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:nearbyDoctorView];
    
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(15, 1, 100, 40)];
    if (kScreenWidth == 414) {
        nameLabel.frame = CGRectMake(20, 1, 100, nearbyDoctorView.frame.size.height - 2);
        nameLabel.font = [UIFont systemFontOfSize:16];
    }
    else{
        nameLabel.frame = CGRectMake(15, 1, 100, nearbyDoctorView.frame.size.height - 2);
        nameLabel.font = [UIFont systemFontOfSize:14];
    }
    nameLabel.text = @"附近的医生";
    nameLabel.textColor = [UIColor blackColor];
    [nearbyDoctorView addSubview:nameLabel];
    
    UIImageView *pushImageView = [[UIImageView alloc]init];
    if (kScreenWidth == 414) {
        pushImageView.frame = CGRectMake(kScreenWidth - 35, (nearbyDoctorView.frame.size.height - 18)/2, 18, 18);
    }
    else{
        pushImageView.frame = CGRectMake(kScreenWidth - 35, (nearbyDoctorView.frame.size.height - 15)/2, 15, 15);
    }
    pushImageView.image = [UIImage imageNamed:@"公用_跳转"];
    [nearbyDoctorView addSubview:pushImageView];
    
    UIButton *pushButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, nearbyDoctorView.frame.size.width, nearbyDoctorView.frame.size.height)];
    [pushButton addTarget:self action:@selector(pushToNearbyDoctor) forControlEvents:UIControlEventTouchUpInside];
    [nearbyDoctorView addSubview:pushButton];
}

-(void)makeNavBar{
    self.navigationItem.title = @"添加医生";
    UIBarButtonItem *backBtnImg = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"公用_返回.png"] style:UIBarButtonItemStylePlain target:self action:@selector(backBtnclicked)];
    backBtnImg.tintColor = [UIColor whiteColor];
    self.navigationItem.leftBarButtonItem = backBtnImg;
}

-(void)backBtnclicked{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma FKSearchBarDelegate
- (void)VoiceConversion{
    MyNSLog("VoiceConversion");
}

- (void)SearchString{
    SearchDoctorsResultViewController *searchResult = [[SearchDoctorsResultViewController alloc]init];
    searchResult.keyWords = searchBar.searchTextField.text;
    [self.navigationController pushViewController:searchResult animated:YES];
}

- (void)pushToNearbyDoctor{
    ConsultDocListViewController *consult=[[ConsultDocListViewController alloc] initWithNibName:@"ConsultDocListViewController" bundle:[NSBundle mainBundle]];
    [self.navigationController pushViewController:consult animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
